/**
 * Created by baiguiren on 1/23/17.
 */


function mul3(n, callback) {
  setTimeout(function () {
    callback(null, n * 3);
  }, 10);
}

function add1(n, callback) {
  setTimeout(function () {
    callback(null, n + 1);
  }, 10);
}


let async = require('async');

//compose的参数可以看作堆栈，最后的函数最先执行
let add1mul3 = async.compose(add1, mul3);
add1mul3(4, function (err, result) {
  console.log(result);
});